//
//  JGHaveOrderModel.m
//  JGRider
//
//  Created by 单启志 on 2018/2/28.
//  Copyright © 2018年 ffq. All rights reserved.
//

#import "JGHaveOrderModel.h"

@implementation JGHaveOrderModel

+(NSDictionary*)mj_replacedKeyFromPropertyName{

    return @{@"Id":@"id"};

}
-(CGFloat)cellHeight{

    CGFloat fromAddressLabHeight=[self sizeWithString:self.fromAddress font:13];
    CGFloat toAddressLabHeight=[self sizeWithString:self.toAddress font:13];
    CGFloat showAllLabHeight=[self sizeWithString:@"展示详情" font:11];
    CGFloat cellHeight=AdaptedHeight(10)+AdaptedHeight(23)+AdaptedHeight(12)+fromAddressLabHeight+toAddressLabHeight+AdaptedHeight(11.5)+AdaptedHeight(20)+AdaptedHeight(11)+showAllLabHeight+AdaptedHeight(37)+AdaptedHeight(10)+AdaptedHeight(10);
    if (self.isShowAll) {
 cellHeight=cellHeight+AdaptedHeight(9)+AdaptedHeight(13)+self.orderDetailsSuperVeiwHeight;
    }else{
        cellHeight+=AdaptedHeight(13);
    }
    return cellHeight;
}

-(CGFloat)orderDetailsSuperVeiwHeight{

    CGFloat orderDetailsLabHeight=[self sizeWithString:self.orderDetails font:13];
    CGFloat customeNameLabHeight=[self sizeWithString:@"顾客姓名：王大力（13650703987)" font:13];
    CGFloat orderDetailsSuperVHeight=AdaptedHeight(10)+orderDetailsLabHeight+AdaptedHeight(9)+customeNameLabHeight+AdaptedHeight(10);

    return orderDetailsSuperVHeight;

}

-(CGFloat)sizeWithString:(NSString*)string font:(CGFloat)font{

    NSDictionary *dic = @{NSFontAttributeName : [UIFont systemFontOfSize:font]};
   CGRect rect=[string boundingRectWithSize:CGSizeMake(JGScreenW-AdaptedHeight(16+16), MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:dic context:nil];
    return rect.size.height;
}

#pragma mark - 转变成有效数据
-(NSString *)fromAddress{
    NSString *fromAddress=self.sellerMap[0][@"sellerAddress"];
    return [NSString stringWithFormat:@"取：%@",fromAddress];
}

-(NSString *)toAddress{
     NSString *toAddress=self.buyerCneeMap[0][@"receiveAddress"];
    return [NSString stringWithFormat:@"送：%@",toAddress];;
}

-(NSString *)orderDetails{
    NSString *details=@"订单明细：";
    for (int i=0; i<self.orderLineInfoList.count; i++) {
        NSString *proteName=self.orderLineInfoList[0][@"productName"];
        NSInteger number=[self.orderLineInfoList[0][@"skuNumber"] integerValue];
        NSString *detail=[NSString stringWithFormat:@"%@(X%ld)；",proteName,number];
       details=[details stringByAppendingString:detail];
    }
    return details;
}

-(NSString *)customName{
   NSString *name= self.bueryerMap[0][@"buyerName"];
   NSString *tel=self.bueryerMap[0][@"buyerPhone"];
    return [NSString stringWithFormat:@"顾客姓名：%@（%@）",name, tel];
}

-(NSString *)orderNum{
   return self.orderCode;
}

-(NSString *)distributionTime{
   NSString*postTime=self.orderLineInfoList[0][@"productPostTime"];
    return postTime;
}

+(NSArray<JGHaveOrderModel*>*)models{
    JGHaveOrderModel *model1=[[JGHaveOrderModel alloc]init];
    model1.fromAddress=@"取：老百姓药房广州设计港分店荔湾区周门北路50号1145房";
    model1.toAddress=@"送：荔湾区周门北路28号荔天大厦5楼";
    model1.orderDetails=@"订单明细：999感冒灵(X1)；银翘解毒片(X1)；保济丸(X2)；";
    JGHaveOrderModel *model2=[[JGHaveOrderModel alloc]init];
    model2.fromAddress=@"取：广州市黄埔区文冲村委牛地街2巷15号光头佬烤鱼店";
    model2.toAddress=@"送：广州市番禺区洛溪大道洛溪南路梧桐树往里走15米";
    model2.orderDetails=@"订单明细：酸菜鱼（X1)；麻辣小龙虾大份(X1)；葱花饼(X10)；猪肚鸡（X1）；毛血旺(X1)；酸辣粉(X2)；狮子头(X10)；酸辣粉(X2)；狮子头(X10)；酸辣粉(X2)；狮子头(X10)；酸辣粉(X2)；狮子头(X10)；酸辣粉(X2)；狮子头(X10)；";
    //model2.isShowAll=YES;
    JGHaveOrderModel *model3=[[JGHaveOrderModel alloc]init];
    model3.fromAddress=@"取：广州市荔湾区漖表幼儿园南门";
    model3.toAddress=@"送：广州市白云区陈田村西约北街24巷2号";
    model3.orderDetails=@"订单明细：叉烧包(X100)";
    NSMutableArray *arr=[NSMutableArray arrayWithObjects:model1,model2,model3, nil];
    return arr.mutableCopy;
}
@end
